package org.example.config;

import com.github.dockerjava.api.DockerClient;
import com.github.dockerjava.core.DefaultDockerClientConfig;
import com.github.dockerjava.core.DockerClientBuilder;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

/**
 * @Description:
 * @Date: 2025/7/28 09:05
 */
@ConfigurationProperties(prefix = "docker.java.config")
@Component
public class DockerJavaConfig {
    private String host;

    public String getHost() {
        return host;
    }

    public void setHost(String host) {
        this.host = host;
    }

    @Bean
    public DockerClient dockerClient(){
        DefaultDockerClientConfig build = DefaultDockerClientConfig.createDefaultConfigBuilder()
                .withDockerHost(getHost())
                .build();
        return DockerClientBuilder.getInstance(build).build();
    }
}
